package com.maslyk.invitation.backing;

import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;

import com.maslyk.configuration.ConfigurationManager;
import com.maslyk.invitation.enums.AdditionalStatusEnum;
import com.maslyk.invitation.enums.OrderStatusEnum;
import com.maslyk.invitation.enums.OrderTypeEnum;
import com.maslyk.invitation.enums.OverPrintColorEnum;
import com.maslyk.invitation.enums.PermissionEnum;
import com.maslyk.invitation.enums.RecordTypeEnum;
import com.maslyk.invitation.enums.TextTypeEnum;

/**
 *
 * @author kris
 */
public class ConstantDictionaries
{
    private List<SelectItem> orderStatus = new ArrayList<SelectItem>();
    private List<SelectItem> additionalStatus = new ArrayList<SelectItem>();
    private List<SelectItem> orderTypes = new ArrayList<SelectItem>();
    private List<SelectItem> textType = new ArrayList<SelectItem>();
    private List<SelectItem> allPermissions = new ArrayList<SelectItem>();
    private List<SelectItem> overPrintColor = new ArrayList<SelectItem>();
    private List<SelectItem> priceTypes = new ArrayList<SelectItem>();
    private List<SelectItem> recordTypes = new ArrayList<SelectItem>();

    public ConstantDictionaries()
    {
        for(OrderStatusEnum orderEnum : OrderStatusEnum.values())
            orderStatus.add(new SelectItem(orderEnum.getStatus(), orderEnum.toString()));
        
        for(AdditionalStatusEnum additionalStatusEnum : AdditionalStatusEnum.values())
        	additionalStatus.add(new SelectItem(additionalStatusEnum.getStatus(), additionalStatusEnum.name()));

        for(TextTypeEnum textEnum : TextTypeEnum.values())
            textType.add(new SelectItem(textEnum.getType(), textEnum.name()));

        for(OverPrintColorEnum colorEnum : OverPrintColorEnum.values())
            overPrintColor.add(new SelectItem(colorEnum.getColor(), colorEnum.name()));
        
        for(OrderTypeEnum orderTypeEnum : OrderTypeEnum.values())
            orderTypes.add(new SelectItem(orderTypeEnum.getPrefix(), orderTypeEnum.name()));
        	
        recordTypes.add(new SelectItem(RecordTypeEnum.ORDER, "Zamówienie"));
        recordTypes.add(new SelectItem(RecordTypeEnum.OFFER, "Oferta"));

        loadPermissions();  // wczytanie uprawnien
        loadPrices();       // zaladowanie cen zaproszen
    }

    public List<SelectItem> getOrderStatus()
    {
        return orderStatus;
    }
    
    public List<SelectItem> getAdditionalStatus()
    {
        return additionalStatus;
    }

    public List<SelectItem> getTextType()
    {
        return textType;
    }

    public List<SelectItem> getAllPermissions()
    {
        return allPermissions;
    }

    public List<SelectItem> getOverPrintColor()
    {
        return overPrintColor;
    }

    public void loadPermissions()
    {
        for(PermissionEnum enm : PermissionEnum.values())
        	allPermissions.add(new SelectItem(enm.name(),enm.name()));
    }

    public void loadPrices()
    {
        String prices = ConfigurationManager.getInstance().getINVITATION_PRICE();

        String [] pricesGroup = prices.split(";");

        String []singlePrice = null;
        for(String group: pricesGroup)
        {
            singlePrice = group.split("=");
            priceTypes.add(new SelectItem(singlePrice[1], singlePrice[0]+" = "+singlePrice[1]));
        }
    }

    public List<SelectItem> getPriceTypes()
    {
        return priceTypes;
    }
    
    public List<SelectItem> getOrderTypes()
    {
        return orderTypes;
    }

	public List<SelectItem> getRecordTypes() 
	{
		return recordTypes;
	}
}
